//
//  HYOUGuidePage.m
//  BestGift
//
//  Created by 温晓宇 on 16/1/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HYOUGuidePage.h"

@implementation HYOUGuidePage

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark -- 审核 引导页
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentSize = CGSizeMake(WIDTH * 4, HEIGHT);
//        self.whiteColor = [UIColor clearColor];
//        self.nightColor = [UIColor clearColor];
        [self setBackgroundColor:[UIColor clearColor]];
        self.pagingEnabled = YES;
        self.bounces = NO;
        for (int i = 1; i < 5; i++) {
            UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * (i - 1), 0, WIDTH, HEIGHT)];
            imgV.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
            [self addSubview:imgV];
            imgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg", i]];
            [imgV release];
            if (i == 4) {
                imgV.userInteractionEnabled = YES;
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(enterAPP)];
                [imgV addGestureRecognizer:tap];
            }
        }
    }
    return self;
}

- (void)enterAPP{
    [UIView animateWithDuration:0.8 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
        [USERDEFAULT setObject:@"YES" forKey:@"notFirstRun"];
    }];
}

@end
